<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class PageSetting extends CI_Controller {
 	public function __construct()
    {
        parent::__construct();
        session_start();
        //$this->output->enable_profiler(FALSE);
    	if (!isset($_SESSION['uid']) || $_SESSION['uid'] < 1){
	    	redirect('cmladministration','refresh');
	    }
	    if($_SESSION['role_id'] == 3)
        {
            redirect('cmladmin/accessdenied','refresh');
        }
        $this->load->model('MPage');
    }
	    
	public function index()
	{
		$data['title'] = "Page Setting";
		$data['main'] = 'admin/pagesetting';
        $data['pageList'] = $this->MPage->getAllAssignedPages($_SESSION['role_id']);
        $data['pageList2'] = $this->MPage->getAllAssignedPages(2);
        $data['pageList3'] = $this->MPage->getAllAssignedPages(3);
		$this->load->vars($data);
		$this->load->view('admin/layout'); 
	}
    
    public function change()
	{
	    if($this->input->post('submit'))
        {
            $this->MPage->updatePageSettings();
        	$this->session->set_flashdata('message','Page Setting Changed.');
        	redirect('pagesetting','refresh');
        }
        redirect('pagesetting','refresh');
	}
 
}
